#ifndef DYNAMICMODEL_H
#define DYNAMICMODEL_H

#include <math.h>
#include <QVector3D>
#include <QQuaternion>

class DynamicModel
{
private:
    float mPitch;
    float mYaw;
    float mRoll;

    QVector3D mEx, mEy, mEz;

protected:
    QVector3D mGravity;

    float mMass;
//    QMatrix3x3 mInertialTensor;

    QVector3D mPosition;
    QVector3D mVelocity;
    QVector3D mAcceleration;

    QQuaternion mRotation;
    QVector3D mAngularVelocity;
    QVector3D mAngularAcceleration;

    QVector3D mForce;
    QVector3D mMomentum;

    friend class DynamicObject3D;

    virtual void integrateStep(float h);

public:
    explicit DynamicModel();

    void integrate(float dt);
    void reset();

    const QVector3D &position() const {return mPosition;}
    void setPosition(QVector3D pos) {mPosition = pos;}

    float pitch() const {return mPitch;}
    float yaw() const {return mYaw;}
    float roll() const {return mRoll;}

    QVector3D ex() const {return mEx;}
    QVector3D ey() const {return mEy;}
    QVector3D ez() const {return mEz;}

    virtual void setControl(float u) {}
    virtual void setControl(float u1, float u2) {}
    virtual void setControl(float u1, float u2, float u3) {}
    virtual void setControl(float u1, float u2, float u3, float u4) {}
};

#endif // DYNAMICMODEL_H
